<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
    <style>
        [v-cloak]{
            display:none;
        }
    </style>
</head>
<body>
    <div id="app">
        <p>{{ msg }}</p>
        <p v-text="msg"></p>
        <p v-html="msg"></p>
        <p v-pre>在Vue中，使用{{msg}}来获取变量msg</p>
        <p v-once>{{ msg }}</p>
        <hr>
        <p v-cloak>{{ msg }}</p>

        <!-- 事件绑定 -->
        <button v-on:click="print()">按钮1</button>
        <button @click="print">按钮2</button>
        <button @click="modifyMsg">按钮3</button>
        <button @click="msg='Welcome'">按钮4</button>
        <button @click="write(25)">按钮5</button>
        <button @click="write(msg)">按钮6</button>
        <!-- $event表示事件对象 -->
        <button @click="write($event)">按钮7</button>
        <input type="text" @input="write($event.target.value)" value="666">
    </div>
</body>
<script>
    // setTimeout(function(){
       var vm = new Vue({
            el:'#app',
            data:{ // 数据仓库
                msg:'<h2>hello world</h2>'
            },
            methods: { // 方法仓库
                print(){
                    console.log('hello world')
                },
                modifyMsg(){
                    // console.log(this)
                    // console.log(this === vm) // this指向当前Vue实例
                    // this.print()
                    this.msg = 'Happy'
                },
                write(args){
                    console.log(args)
                }
            },
        })
    // },2000)
</script>
</html>